var curr="1";
var pageSize="10";
var table;
var layer;
var fileId,fpath;
var is_first = true;

var UPLOAD = 0;
var DOWNLOAD = 1;
var DELETE = 2;
var MKDIR = 3;
var SHARE = 4;
var RENAME = 5;

var deleteObj;
var currentDepartmentFolderName;

$(function () {
    sessionStorage.setItem("departmentFilePath","部门");
    getDepartmentName();
    //隐藏搜索栏
    showSearch(is_first);
    //获取表格数据
    getAllFilesList(0,10);
    

})
/**
 * 后台返回数据填充表格 demo
 */
function getAllFilesList(currt,size) {
    layui.use('layer', function () { //独立版的layer无需执行这一句
        var $ = layui.jquery;
        layer = layui.layer; //独立版的layer无需执行这一句
    })
    var page={};
    page.currt=currt;
    page.size=size;
    var obsFile={};
    obsFile.userId=0;
    obsFile.fileState=1;
    if(sessionStorage.getItem("departmentFilePath")!=""){
        obsFile.path=sessionStorage.getItem("departmentFilePath")+"/";
    }
    var obj={};
    obj.obsFile=obsFile;
    obj.page=page;
    $.ajax({
        url: sessionStorage.getItem("rootPath") + "/files/slectFileList",
        method: "post",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        data: JSON.stringify(obj
        ),
        success: function (res) {
            if(is_first){
	          renderTableFirst(res);
            }else{
	          renderTable(res);
            }
            renderpage(res);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
        }
    })
}

/**
 * 模糊查询
 */
function getFilesList() {
    var obsFile={};
    obsFile.userId= 0;
    obsFile.fileState=1;
    obsFile.fileName=$("#filename").val();
    obsFile.path="部门/"+sessionStorage.getItem("department");

    $.ajax({
        url: sessionStorage.getItem("rootPath") + "/files/selectFile",
        method: "post",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        data: JSON.stringify(obsFile),
        success: function (res) {
            renderTable(res);
            renderpage(res.data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
        }
    })
}

/**
 * 表格渲染
 */
function renderTable(data) {
    layui.use('table', function () {
        table = layui.table;
        table.render({
            elem: '#allFilesTable'
            ,url: '../../admin/data/common.json'
            , page: false
            , height: 490
            ,toolbar: '#toolbar' //开启头部工具栏，并为其绑定左侧模板
            ,defaultToolbar: []
            , parseData: function (res) {
                return {
                    "code": 0,
                    "msg": "",
                    "data": data.data
                }
            }
            , cols: [[
                {type:'checkbox',width:60},
                {field: 'type',width:80,title: '图标', templet:function (data) {
                        if(data.type=="图片"){
                            return '<img src="admin/images/tag_image.png" style="width:30px;"/>';
                        }else if(data.type=="文档"){
                            return '<img src="admin/images/tag_word.png" style="width:30px;"/>';
                        }else if(data.type=="音乐"){
                            return '<img src="admin/images/tag_music.png" style="width:30px;"/>';
                        }else if(data.type=="视频"){
                            return '<img src="admin/images/tag_video.png" style="width:30px;"/>';
                        }else if(data.type=="文件夹"){
                            return '<img src="admin/images/tag_folder.png" style="width:30px;"/>';
                        }else if(data.type=="Word"){
                            return '<img src="admin/images/tag_word.png" style="width:30px;"/>';
                        }else if(data.type=="Pdf"){
                            return '<img src="admin/images/tag_pdf.png" style="width:30px;"/>';
                        } else if(data.type=="Excel"){
                            return '<img src="admin/images/tag_excel.png" style="width:30px;"/>';
                        }else if(data.type=="Ppt"){
                            return '<img src="admin/images/tag_ppt.png" style="width:30px;"/>';
                        }else if(data.type=="其他"){
                            return '<img src="admin/images/tag_other.png" style="width:30px;"/>';
                        }
                    }}
                , {field: 'fileName', title: '文件名',sort:true, templet: function (data) {
                        return "<a href='javascript:void(0)' style='color: #1aa5fb'"+" onclick=openFile('" + escape(data.path) + "','"+data.type+"')>" + data.fileName + "</a>";
                    }}
                , {field: 'size',title: '文件大小',sort:true, templet: function (data) {
                        if(data.type=="文件夹"){
                            return "--";
                        }else {
                            return data.size;
                        }
                    }}
                , {field: 'makeTime',title: '上传时间',sort:true, templet: function (data) {
                        if(data.type=="文件夹"){
                            return "--";
                        }else {
                            return data.makeTime;
                        }
                    }}
                , {fixed: 'right', title: '操作',templet:function (data) {
                        var btns = "";
                            btns += ' <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete"><i class="layui-icon layui-icon-delete"></i>删除</a>';
                            btns += ' <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="preview"><i class="layui-icon layui-icon-refresh"></i>重命名</a>';
                        return btns;
                    }}
            ]]
        });

        //监听行工具事件
        table.on('sort(allFilesTable)',function (obj){
            getFilesListByOrder(obj.field,obj.type)
        });
        table.on('tool(allFilesDemo)', function (obj) {
	        deleteObj = obj;
            var data = obj.data;
            if (obj.event === 'delete'){
                layer.confirm('真的删除该文件/文件夹吗？', function(index){
                    deleteFile(data.fileId,data.path,data.type);
                    //obj.del();
                });
            }else if(obj.event === 'preview'){
                var data = obj.data;
                if(data.type=="文件夹"){
                    layer.msg("文件夹暂时不能重命名哦！")
                }else{
                    layer.prompt({title: '输入新名称', formType: 0,value:data.fileName},function(fileName, index){
                        var obsFile={};
                        obsFile.userId=0;
                        obsFile.fileName=data.path;
                        obsFile.fileId=data.fileId;
                        obsFile.path=data.path.substring(0,data.path.length-data.fileName.length)+fileName;
                        $.ajax({
                            url: sessionStorage.getItem("rootPath") + "/files/rename",
                            data:JSON.stringify(obsFile),
                            dataType:'json',
                            contentType: 'application/json;charset=utf-8',
                            type:'post',
                            success:function(res){
                                if (res==1){
                                    layer.msg("重命名成功！",{icon:1,time:1000},function () {
                                        getAllFilesList(curr-1,10);
                                        layer.close(index);
                                    });
                                }else {
                                    layer.msg("已存在同名文件，请重新命名！",{icon:2,time:1000},function () {
                                        layer.close(index);
                                    });
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                layer.msg("重命名失败！" ,{icon:2,time:1000});
                                console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
                            }
                        })
                    });
                }
            }
        });
    });
}

/**
 * 表格渲染
 */
function renderTableFirst(data) {
    layui.use('table', function () {
        table = layui.table;
        table.render({
            elem: '#allFilesTable'
            ,url: '../../admin/data/common.json'
            , page: false
            , height: 490
            ,defaultToolbar: []
            , parseData: function (res) {
                return {
                    "code": 0,
                    "msg": "",
                    "data": data.data
                }
            }
            , cols: [[
                {field: 'type',width:150,title: '图标', templet:function (data) {
                            return '<img src="admin/images/tag_folder.png" style="width:30px;"/>';                    
                }}
                , {field: 'fileName', title: '文件名',sort:true, templet: function (data) {
                        return "<a href='javascript:void(0)' style='color: #1aa5fb'"+" onclick=openDepartmentFolder('" + escape(data.path) + "','"+data.fileName+"')>" + data.fileName + "</a>";
                    }}
            ]]
        });

        //监听行工具事件
        table.on('sort(allFilesTable)',function (obj){
            getFilesListByOrder(obj.field,obj.type)
        });
    });
}

function getFilesListByOrder(field,type){

}


/**
 * 删除文件
 */
function deleteFile(id,path,type) {
    var obsFile = {};
    obsFile.fileId=id;
    obsFile.userId=0;
    obsFile.path=path;
    obsFile.type=type;
    $.ajax({
        url: sessionStorage.getItem("rootPath") + "/files/deleteFile",
        data:JSON.stringify(obsFile),
        dataType:'json',
        contentType: 'application/json;charset=utf-8',
        type:'post',
        success:function(res){
            if(res==0){
                layer.msg("删除文件/文件夹失败！",{icon:0,time:1000});
            }else{
                layer.msg("删除文件/文件夹成功！",{icon:1,time:1000});
                deleteObj.del();
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            layer.msg("删除文件/文件夹出错！" ,{icon:2,time:1000});
            console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
        }
    })
}
/**
 * 分页
 */
function renderpage(date) {
    layui.use('laypage', function () {
        var laypage = layui.laypage;

        //执行一个laypage实例
        laypage.render({
            elem: 'allFilesTable_page' //注意，这里的 test1 是 ID，不用加 # 号
            , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            , count: date.total //数据总数，从服务端得到
            , limits: [10,20, 30]
            , curr: curr
            , limit: pageSize
            , jump: function (obj, first) {
                //首次不执行
                if (!first) {
                    curr = obj.curr;
                    pageSize = obj.limit;
                    getAllFilesList(curr-1,pageSize);
                }
            }
        });

    });
}

/**
 * 新建文件夹
 */
function addFloder() {
    layui.use('layer', function () { //独立版的layer无需执行这一句
        var $ = layui.jquery; layer = layui.layer; //独立版的layer无需执行这一句
        layer.prompt({title: '输入文件夹名称', formType: 2}, function(fileName, index){
            var obsFile={};
            obsFile.userId=0;
            obsFile.fileName=fileName;
            obsFile.fileState="1";
            if(sessionStorage.getItem("departmentFilePath")==""){
                obsFile.path=sessionStorage.getItem("departmentFilePath")+fileName;
            }else{
                obsFile.path=sessionStorage.getItem("departmentFilePath")+"/"+fileName;
            }
            $.ajax({
                url: sessionStorage.getItem("rootPath") + "/files/addFloder",
                data:JSON.stringify(obsFile),
                dataType:'json',
                contentType: 'application/json;charset=utf-8',
                type:'post',
                success:function(res){
                    if(res == 1){
	                    layer.msg("创建文件夹成功！",{icon:1,time:1000},function () {
                        getAllFilesList(curr-1,pageSize);
                        layer.close(index);
                    });
                    }else{
	                    layer.msg("创建文件夹失败！",{icon:1,time:1000},function () {
                        getAllFilesList(curr-1,pageSize);
                        layer.close(index);
                    });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.msg("创建文件夹出错！" ,{icon:2,time:1000});
                    console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
                }
            })
        });
    });
}
/**
 * 下载文件
 */
function ObsDownload() {
    var checkStatus=table.checkStatus("allFilesTable");
    if(checkStatus.data.length>0){
        //遍历下载
        for(var i=0;i<checkStatus.data.length;i++){
	        console.log(checkStatus.data[i]);
            if(checkStatus.data[i].type!="文件夹"){
                var res = "https://didacloudpan.obs.cn-north-4.myhuaweicloud.com/"+checkStatus.data[i].path+'?response-content-disposition=attachment';
                window.open(res,"_blank");
            }else{
                layer.msg("文件夹暂时不支持下载！")
            }
        }
    }else {
        layui.use('layer', function() { //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
            layer.alert('请至少选择一个文件');
        })
    }
}
/**
 * 移动
 */
function ObsMove() {
    layer.msg('玩命开发中...');
}
/**
 * 复制
 */
function ObsCopy() {
    layer.msg('玩命开发中...');

    /*var checkStatus=table.checkStatus("allFilesTable");
    if(checkStatus.data.length>0){
        //弹窗选文件
        layui.use('layer', function () { //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
            layer.open({
                type: 2,
                title: '选择目的文件夹',
                skin: 'layui-layer-molv', //样式类名
                shade: 0.8,
                shadeClose:false,
                area: ['50%', '70%'],
                content: 'chooseFolder.html',
                btn: ['确定','关闭'],
                yes: function(layero, index){
                    var res = window["layui-layer-iframe" + index].callbackData();
                    if (res != null || res != '') {
                        if (res == 'false') {
                            return;
                        } else {
                            console.log(res.fileId+res.fpath);
                            fileId=res.fileId;
                            fpath=res.fpath;
                            //遍历复制文件
                            for (var i;i<checkStatus.data.length;i++){
                                copyFiles(checkStatus.data[i].fileName);
                            }
                            layui.use('layer', function() { //独立版的layer无需执行这一句
                                var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
                                layer.msg("复制文件成功！",{icon:1,time:1000},function () {});
                            })
                        }
                    }
                }
            });
        });
    }else {
        layui.use('layer', function() { //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
            layer.alert('请至少选择一个文件/文件夹');
        })
    }*/
}

/*function copyFiles(fileId,fileName) {
    var obsFile={};
    obsFile.userId=sessionStorage.getItem("id");
    obsFile.path=fpath;
    obsFile.fileName=fileName;
    $.ajax({
        method: "post",
        url:sessionStorage.getItem("rootPath")() +  "/files/copy",
        dataType:"json",
        contentType: 'application/json;charset=utf-8',
        data:JSON.stringify(obsFile),
        async: false,
        timeout : 50000, //超时时间：50秒
        success: function (data) {

        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
        }
    })
}*/
/**
 * 返回上一级
 */
function returnParentFolder(){
    var obsFile={};
    obsFile.userId=0;
    obsFile.path=sessionStorage.getItem("departmentParentPath");
    if(obsFile.path == "部门/"){
	   is_first = true;
    }else{
	   is_first = false;
    }
    console.log(is_first);
    obsFile.fileState=1;
    var page={};
    page.currt=0;
    page.size=10;
    var obj={};
    obj.obsFile=obsFile;
    obj.page=page;
    var p=sessionStorage.getItem("departmentParentPath");
    p=p.substring(0,p.length-1);
    sessionStorage.setItem("departmentFilePath",p);
    $.ajax({
        url: sessionStorage.getItem("rootPath") + "/files/slectFileList",
        method: "post",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        data: JSON.stringify(obj),
        success: function (res) {
            var path = obsFile.path;
            path = path.substring(0,path.length-1);
            curr=1;
            while (path.charAt(path.length-1)!='/'){
                path=path.substring(0,path.length-1);
                if(path==""){
                    break;
                }
            }
            if(path!=""){
                sessionStorage.setItem("departmentParentPath",path);

            }
            if(is_first){
	          renderTableFirst(res);
            }else{
	          renderTable(res);
            }
            showSearch(is_first);
            renderpage(res);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
        }
    })
}

function openDepartmentFolder(path,name){
	is_first = false;
	//console.log(is_first);
	//console.log("路径 "+path);
	//console.log("名字 "+name);
	currentDepartmentFolderName = name;
    var obsFile={};
    obsFile.userId=0;
    path=unescape(path);
    obsFile.path=path+"/";
    obsFile.fileState=1;
    var page={};
    page.currt=0;
    page.size=10;
    var obj={};
    obj.obsFile=obsFile;
    obj.page=page;
    $.ajax({
        url: sessionStorage.getItem("rootPath") + "/files/slectFileList",
        method: "post",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        data: JSON.stringify(obj),
        success: function (res) {
            sessionStorage.setItem("departmentFilePath",path);
            while (path.charAt(path.length-1)!='/'){
                path=path.substring(0,path.length-1);
            }
            console.log(path);
            sessionStorage.setItem("departmentParentPath",path);
            sessionStorage.setItem("department",name+"/");
            showSearch(false);
            renderTable(res);
            renderpage(res);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
        }
    })
}

/**
 * 打开文件
 */
function openFile(path,type) {
    /*if(type=="图片" || type=="视频" || type=="音乐"){
        var obsFile={};
        obsFile.userId=0;
        obsFile.fileState=1;
        path=unescape(path);
        obsFile.path=path;
        $.ajax({
            url: sessionStorage.getItem("rootPath") + "/files/preview",
            method: "post",
            dataType: "text",
            contentType: 'application/json;charset=utf-8',
            data: JSON.stringify(obsFile),
            success: function (res) {
                window.open(res,"_blank");
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
            }
        })*/
    path=unescape(path);
    if(type=="图片" || type=="视频" || type=="音乐"){
        var obsFile={};
        obsFile.userId=0;
        obsFile.fileState=1;
        obsFile.path=path;
        $.ajax({
            url: sessionStorage.getItem("rootPath") + "/files/preview",
            method: "post",
            dataType: "text",
            contentType: 'application/json;charset=utf-8',
            data: JSON.stringify(obsFile),
            success: function (res) {
                                	     //判断res是什么格式的
	
	     var html="";
         //mp3|.wav
         if(res.includes(".mp3")||res.includes(".wav")){
	         html="<audio src='" + res + "' controls  width='500px' height='500px'/>";
          
         }
          //.mp4|.wmv
         else if(res.includes(".mp4")||res.includes(".wmv")){
	         
	         html="<video src='" + res + "' controls  width='500px' height='500px'/>";
         
         }
         else{
	     var img = new Image(); 
         img.src = res;
          html = "<img src='" + img.src + "' width='500px' height='500px'/>"; 
         }
            
	     
   //弹出层
   layer.open({ 
     type: 1, 
     shade: 0.8,
     offset: 'auto',
     area: [500 + 'px',500+'px'], //
     shadeClose:true,
     scrollbar: false,
     title: "预览", 
     content: html,  
     cancel: function () { 
       
     } 
   }); 
     html="";
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
            }
        })
      }else if(type=="Word" || type=="Excel" || type=="Ppt"){
	    var res = "https://didacloudpan.obs.cn-north-4.myhuaweicloud.com/"+path+'?response-content-disposition=attachment';
	    window.open('https://view.officeapps.live.com/op/view.aspx?src='+res,"_blank")
      }else if(type=="Pdf"){
	     window.open("https://didacloudpan.obs.cn-north-4.myhuaweicloud.com/" + path, "_blank");
    }else if(type=="文件夹")
    {
	    console.log("名字 "+name);
	    is_first = false;
        console.log(is_first);
        var obsFile={};
        obsFile.userId=0;
        path=unescape(path);
        obsFile.path=path+"/";
        obsFile.fileState=1;
        var page={};
        page.currt=0;
        page.size=10;
        var obj={};
        obj.obsFile=obsFile;
        obj.page=page;
        $.ajax({
            url: sessionStorage.getItem("rootPath") + "/files/slectFileList",
            method: "post",
            dataType: "json",
            contentType: 'application/json;charset=utf-8',
            data: JSON.stringify(obj),
            success: function (res) {
                sessionStorage.setItem("departmentFilePath",path);
                while (path.charAt(path.length-1)!='/'){
                    path=path.substring(0,path.length-1);
                }
                sessionStorage.setItem("departmentParentPath",path);
                showSearch(false);
                renderTable(res);
                renderpage(res);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
            }
        })
    }else{
        layui.use('layer', function() { //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
            layer.alert('该文件暂时不支持预览！');
        })
    }
}

/*
显示搜索框
 */
function showSearch(is_first) {
	if(is_first){
		document.getElementById( "search").style.display= "none";
	}else{
		document.getElementById( "search").style.display= "block" ;
	}
}

function authoritySetting(){
    	/*if(sessionStorage.getItem("role") == 0 || currentDepartmentFolderName != sessionStorage.getItem("departmentName")){
    		layer.msg('无权限...');
    	}else{
    		layui.use('layer', function(){
    			var $ = layui.jquery,layer = layui.layer;
    			var checkStatus=table.checkStatus("allFilesTable");
    			window.PartitionId=checkStatus;//id 是需要传递的数据
    			layer.open({
    				type: 2 //Page层类型
    				,area: ['500px', '400px']
    				,title: '权限设置'
    				,shade: 0.6 //遮罩透明度
    				,maxmin: true //允许全屏最小化
    				,anim: 0 //0-6的动画形式，-1不开启
    				,content: 'upSetting.html'
    			});
    		});
    	}*/
        if(sessionStorage.getItem("role") == 2 || (sessionStorage.getItem("role") == 1 && currentDepartmentFolderName == sessionStorage.getItem("departmentName"))){
            layui.use('layer', function(){
    			var $ = layui.jquery,layer = layui.layer;
    			var checkStatus=table.checkStatus("allFilesTable");
    			window.PartitionId=checkStatus;//id 是需要传递的数据
    			layer.open({
    				type: 2 //Page层类型
    				,area: ['500px', '400px']
    				,title: '权限设置'
    				,shade: 0.6 //遮罩透明度
    				,maxmin: true //允许全屏最小化
    				,anim: 0 //0-6的动画形式，-1不开启
    				,content: 'upSetting.html'
    			});
    		});
        }else{
	        layer.msg('无权限...');
        }
}
//请求文件的权限
function getPermission(departmentId,fileId){
	var permission;
	var obsFile={};
	obsFile.departmentId = departmentId;
     $.ajax({
	          url: sessionStorage.getItem("rootPath") + "/files/permission/"+fileId,
	          data:obsFile,
	          type:'GET',
	          success:function(res){
	             permission = binary(res.data,6);
                 console.log(permission);
	          },
	          error: function (XMLHttpRequest, textStatus, errorThrown) {
	             console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
	          }
	  })
     return permission;
}
//获取部门文件夹对应的部门id
function getDepartmentName(){
	var department={};
	 $.ajax({
            url: sessionStorage.getItem("rootPath") + "/departments/selectDepartmentList",
            method: "post",
            dataType: "json",
            contentType: 'application/json;charset=utf-8',
            data: JSON.stringify(department),
            success: function (res) {
                departmentresult=res;
                //$("#selectRange").prepend("<option value='0'>请选择</option>");//添加第一个option值
                //console.log(departmentresult.data.length);
                for (var i=0; i<departmentresult.data.length;i++){
                    if(sessionStorage.getItem("departmentId") == departmentresult.data[i].id){
	                       sessionStorage.setItem("departmentName",departmentresult.data[i].departmentName);
                           console.log("部门名称 "+sessionStorage.getItem("departmentName"));
                     }
                }

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log("失败" + XMLHttpRequest.status + ":" + textStatus + ":" + errorThrown);
            }
        })
}